﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FourKill.Engine;
using System.Drawing;

namespace FourKill.Engine
{
    public abstract class BaseGameObject : Placement, IGameObject
    {
        protected static readonly Random _rand = new Random();
        protected IObjectViewLocation _locationRelativeToCamera;

        public abstract void Tick();

        public virtual IObjectViewLocation LocationRelativeToCamera
        {
            get
            {
                return _locationRelativeToCamera;
            }
            set
            {
                _locationRelativeToCamera = value;
            }
        }

        public virtual void UpdateLocation(IPaintableContext context)
        {
            if (LocationRelativeToCamera == null) LocationRelativeToCamera = new ObjectViewLocation();
            Utility.CalculateObjectViewLocation(ref _locationRelativeToCamera, context.Camera, context.ViewPort, this);
        }

        public virtual int FrameIndex { get; set; }

        public virtual int ObjectId { get; set; }

        public virtual string ObjectName { get; set; }

        public virtual double Speed { get; set; }

        public virtual Color Color { get; set; }

        public virtual Size CollisionArea  {get; set;}

        public abstract IPaintable Painter { get; }
        
        public virtual object this[string key]
        {
            get
            {
                return null;
            }
        }

        public virtual T Data<T>(string key)
        {
            return (T)this[key];
        }


        public List<Coordinates3D> Path
        {
            get;
            set;
        }
    }
}
